package nc.ui.uif2.actions;

import java.awt.event.ActionEvent;
import javax.swing.Action;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.uif2.NCAction;

public class ConfirmInterceptor
  implements ActionInterceptor
{
  private String msg;

  public ConfirmInterceptor(String msg)
  {
    this.msg = msg;
  }

  public boolean afterDoActionFailed(Action action, ActionEvent e, Throwable ex)
  {
    return true;
  }

  public void afterDoActionSuccessed(Action action, ActionEvent e)
  {
  }

  public boolean beforeDoAction(Action action, ActionEvent e) {
    return MessageDialog.showOkCancelDlg(((NCAction)action).getToftPanel(), "", this.msg) == 1;
  }

  public String getMsg()
  {
    return this.msg;
  }

  public void setMsg(String msg) {
    this.msg = msg;
  }
}